var htmlwp  = require('html-webpack-plugin');
//vue-loader1.5版本以上需要这个插件
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
    entry: './src/main.js',
    output: {
        path: __dirname+'/dist',
        filename: 'build.js'
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ['style-loader','css-loader']
            },
            {
                test: /\.scss$/,
                use: ['style-loader','css-loader','sass-loader']
            },
            {
                test: /\.less/,
                use: ['style-loader','css-loader','less-loader']
            },
            {
                test: /\.(png|jpg|gif|ttf|svg)/,
                use: [
                    {
                        loader: 'url-loader',
                        options: {  
                            limit: 20000,  //小于2KB,就base64编码  
                        } 
                    }
                ]
            },
            {
                test: /\.js$/,
                exclude:/node_modules/,
                use: [
                    {
                        loader:'babel-loader', 
                        options:{
                            presets: ['es2015'],
                            plugins: ['transform-runtime']
                        }
                    }
                ]            
            },
            {
                test: /\.vue$/,
                use: ['vue-loader']
            },
            {
                test: /vue-preview.src.*?js$/,//vue-preivew组件专用
                use: ['babel']
            }
        ]
    },
    plugins: [
        new VueLoaderPlugin(),
        new htmlwp({
            title: '首页',
            filename: 'index.html',
            template: 'index1.html'
        })
    ]
};
